import 'package:cached_network_image/cached_network_image.dart';
import 'package:fish_redux/fish_redux.dart';
import 'package:flutter/material.dart' hide Action;
import 'package:www.znpigai.teacher/global_store/state.dart';

import 'action.dart';
import 'state.dart';

Widget buildView(
    StudentState state, Dispatch dispatch, ViewService viewService) {
  return Container(
    child: Card(
        color: Colors.white,
        elevation: 2.0,
        margin: new EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0),
        child: ListTile(
          onTap: () => dispatch(StudentActionCreator.onClick(state.id)),
          leading: CachedNetworkImage(
            width: 40,
            height: 40,
            placeholder: (context, url) => CircularProgressIndicator(),
            errorWidget: (context, url, error) =>
                Image.asset("assets/images/user.png"),
            imageUrl: GlobalState.baseUrl(state.headImage),
          ),
          title: Text(state.name),
          subtitle: Text('手机号：${state.mobile}'),
          trailing: Row(
            mainAxisSize: MainAxisSize.min,
            children: <Widget>[
              // Text('点击修改密码'),
              ImageIcon(
                AssetImage("assets/images/right.png"),
                size: 24.0,
              )
            ],
          ),
        )),
  );
}
